package net.xuzhen97.distributed.transaction.order.manager.microservice;

import net.xuzhen97.distributed.transaction.order.common.Constant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

/**
 * 课程feign客户端，调用课程微服务的接口
 * @author xuzhen97
 */
@FeignClient(
        name = "courseClient",
        url = "${micro-service.course}", configuration = CourseClientConfiguration.class)
@Component
public interface CourseClient {

    /**
     * 开通课程
     * @param opUserId 操作用户，当前用户id
     * @param cmd 开通课程的参数封装
     * @return 返回关联关系id
     */
    @PostMapping("/open-course")
    ResponseEntity<String> openCourse(@RequestHeader(Constant.HEADER_CURRENT_USER_ID) String opUserId
            , @RequestBody OpenCourseCmd cmd);
}
